package co.com.services.eps;

import javax.naming.NamingException;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import co.com.smart.maestro.infraestructure.dto.EpsDTO;
import co.com.smart.session.DelegateContextEJB;


@Path("/SmartEpsServices")
public class EpsServices {
		@GET
		@Path("/getAllEps")	
		@Produces(MediaType.APPLICATION_JSON)
		public Response getEps() throws NamingException {
			return Response.ok(DelegateContextEJB.getEpsBeanLocal().consultarAllEps())
			.header("Access-Control-Allow-Origin", "*")
			.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
			.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build();
		}

		@POST
		@Path("/getEpsId")	
		@Produces(MediaType.APPLICATION_JSON)
		public Response getEpsId(EpsDTO json) throws NamingException {
			return Response.ok(DelegateContextEJB.getEpsBeanLocal().consultarEpsId(json))
			.header("Access-Control-Allow-Origin", "*")
			.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
			.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build();
		}

		@PUT
		@Path("/setEps")
		@Consumes(MediaType.APPLICATION_JSON)
		@Produces(MediaType.APPLICATION_JSON)
		public Response setEps( EpsDTO json){ 
			return Response.ok(DelegateContextEJB.getEpsBeanLocal().insertarEps(json))
					.header("Access-Control-Allow-Origin", "*")
					.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
					.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With")
					.build();
		}

		@PUT
		@Path("/editEps")
		@Consumes(MediaType.APPLICATION_JSON)
		@Produces(MediaType.APPLICATION_JSON)
		public Response setEditEps(EpsDTO json){ 
			return Response.ok(DelegateContextEJB.getEpsBeanLocal().editEps(json))
			.header("Access-Control-Allow-Origin", "*")
			.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
			.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build();
		}

		@PUT
		@Path("/removeEps")
		@Consumes(MediaType.APPLICATION_JSON)
		@Produces(MediaType.APPLICATION_JSON)
		public Response setRemoveEps(EpsDTO json){ 
			return Response.ok(DelegateContextEJB.getEpsBeanLocal().removeEps(json, true))
					.header("Access-Control-Allow-Origin", "*")
					.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
					.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build();
		}

}
